package org.demo.serv; /**
 * Created by tangwy on 2016/1/7.
 */

import java.io.*;
import java.net.*;
import java.util.Arrays;

public class Server {
    private static final int BUFFER_SIZE = 1024;
    private volatile static boolean isAlive = true;

    public static void start() {
        ServerSocket serverSocket = null;
        try {
            serverSocket = new ServerSocket(30000);
        } catch (IOException e) {
            System.out.println("can not listen to:" + e);
            e.printStackTrace();
            return;
        }
        try {
            while (isAlive) {
                new Thread(new ServerThread(serverSocket.accept())).start();
            }
        } catch (IOException e) {
            //System.out.println("");
            e.printStackTrace();
        }
        //accept.
    }
}
